import { onBeforeUnmount, onMounted, reactive } from 'vue'
export default function (data: any) {
  console.log(data, 'data')
  const point = reactive({
    x: 0,
    y: 0
  })
  function savePoint(e: { pageX: any; pageY: any }) {
    point.x = e.pageX
    point.y = e.pageY
    console.log(e.pageX, e.pageY)
  }
  onMounted(() => {
    window.addEventListener('click', savePoint)
  })
  onBeforeUnmount(() => {
    window.removeEventListener('click', savePoint)
  })
  return point
}
